<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Axios</title>
    <script src="axios-0.18.0.js"></script>
</head>

<body>
    <input type="button" name="" id="" onclick="getUser()" value="get请求">
    <input type="button" name="" id="" onclick="postUser()" value="post请求">
</body>

<script>
    function getUser() {


        //通过axios发送异步请求-get
        axios({
            method: "get",
            url: "http://localhost:8080/get"
        }).then(result => {
            console.log("name");
            console.log(result.data);
            result.data.console;
        })
    }

    function postUser() {
        axios({
            method: "post",
            url: "http://localhost:8080/postUser",
            data: "id=3"
        }).then(result => {
            console.log("发送成功")
        })
    }
</script>

</html>